<template>
	<view class="content">
		<view class="top">
			<view class="icon" @tap="go_info">
				<image @tap.stop="prevIcon" :src="img" class="tou"></image>
				<view class="nickName">
					<text class="nick">{{user.nickName}}</text>
					<text class="desc">{{user.description}}</text>
				</view>
				<view class="setting" @tap.stop="setting()">
					<uni-icon type="arrowright" size="28" color="#ffffff"></uni-icon>
				</view>
			</view>
			<view class="star">
				<view><text @tap="go_touch">关注: {{touch}}</text></view>
				<view><text @tap="go_star">粉丝: {{star}}</text></view>
			</view>
		</view>

		<view @tap="process(index)" :key="index" v-for="(item,index) in func" class="fun">
			<image class="left" :src="item.path" mode=""></image>
			<view>{{item.title}}</view>
			<!-- <image class="right" src="../../static/images/right.png"></image> -->
			<uni-icon type="arrowright" size="28" color="#999"></uni-icon>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import utils from "../../static/js/utils.js"
	import uniIcon from "@/components/uni-icon/uni-icon.vue"
	export default {
		computed: {
			...mapState(['user', 'star', 'touch']),
			img() {
				return utils.baseImgUrl + this.user.imgUrl
			}
		},
		components: {
			uniIcon
		},
		data() {
			return {
				func: [{
						title: '我的活动',
						path: '../../static/images/huodong.png'

					},
					{
						title: '我的快递',
						path: '../../static/images/kuaidi.png'

					},
					{
						title: '意见反馈',
						path: '../../static/images/yijian.png'

					},
					{
						title: '关于我们',
						path: '../../static/images/about.png'

					}
				]
			};
		},
		methods: {
			go_info() {
				uni.navigateTo({
					url: 'userinfo?userId=' + this.user.id
				});
			},
			go_touch() {
				uni.navigateTo({
					url: '../touched/touched'
				});
			},
			go_star() {
				uni.navigateTo({
					url: '../touched/star'
				});
			},
			process(index) {
				if (index == 0) {
					uni.navigateTo({
						url: 'useractivity'
					});
				} else if (index == 1) {
					uni.navigateTo({
						url: 'myexpress'
					});
				} else if (index == 2) {
					uni.navigateTo({
						url: '../yijian/yijian'
					});
				} else if (index == 3) {
					uni.navigateTo({
						url: '../about/about'
					});
				}

			},
			...mapMutations(['setInfo']),
			setting() {
				uni.navigateTo({
					url: '../setting/setting',
					animationType: 'fade-in',
					animationDuration: 200
				});
			},
			prevIcon() {
				let urls = [this.img];
				let curent = urls[0];
				uni.previewImage({
					current: curent,
					urls: urls
				})
			},
			getInfoByNet() {
				var that = this;
				uni.stopPullDownRefresh();
				utils.get("user/userinfo", {}, function(data) {
					that.setInfo({
						user: data.user,
						star: data.star,
						touch: data.touch
					})
				});
			},
		},
		onPullDownRefresh() {
			this.getInfoByNet();
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f4f4f4;
	}

	.content {
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

	.top {
		display: flex;
		flex-direction: column;
		justify-content: center;
		width: 100%;
		height: 430upx;
		background: linear-gradient(to bottom, #FF998B, #FFB272);
		margin-bottom: 40upx;
	}

	.icon {
		display: flex;
		flex-direction: row;
		width: 100%;
		height: 200upx;
		// align-items: center;
		justify-content: flex-start;
		margin-top: 130upx;

	}

	.tou {
		width: 160upx;
		height: 160upx;
		border-radius: 200upx;
		margin-left: 30upx;
	}

	uni-icon {
		margin-right: 30upx;
	}

	.nickName {
		height: 160upx;
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: flex-start;
		margin-left: 20upx;
		margin-top: 20upx;
		color: #ffffff;
	}

	.nick {
		font-size: 40upx;
	}

	.desc {
		font-size: 28upx;
		width: 420upx;
		margin-top: 14upx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.setting {
		width: 100upx;
		height: 160upx;
		line-height: 160upx;
		text-align: right;
	}


	.star {
		width: 100%;
		height: 100upx;
		border-radius: 30upx;
		text-align: center;
		display: flex;
		font-size: 32upx;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin-bottom: 20upx;
	}

	.star view {
		width: 30%;
		height: 100upx;
		text-align: center;
		line-height: 110upx;
		color: #ffffff;
	}

	.fun {
		width: 100%;
		height: 110upx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		background-color: #ffffff;
		box-shadow: inset 0px -1px 1px -1px #c8c7cc;
	}

	.fun .left {
		width: 50upx;
		height: 50upx;
		margin-left: 30upx;
	}

	.fun view {
		flex: 1;
		height: 110upx;
		font-size: 35upx;
		margin-left: 30upx;
		line-height: 110upx;
	}
</style>
